package com.hxgz.steel.service.Impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hxgz.steel.common.ServerResponse;
import com.hxgz.steel.dao.InformationMapper;
import com.hxgz.steel.dao.NewsManagerMapper;
import com.hxgz.steel.domain.InformationWithBLOBs;
import com.hxgz.steel.domain.NewsManager;
import com.hxgz.steel.domain.Page;
import com.hxgz.steel.service.InformationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@Service("informationService")
public class InformationServiceImpl implements InformationService{
    @Autowired
    private InformationMapper informationMapper;
    @Autowired
    private NewsManagerMapper newsManagerMapper;

    public ServerResponse informationList(Page page, Integer type){
        PageHelper.startPage(page.getCurrPageNo(),page.getPageSize());
        List<NewsManager> informationWithBLOBs = newsManagerMapper.queryInformationList(type);
        PageInfo pageinfo = new PageInfo(informationWithBLOBs);
        return ServerResponse.createBySuccess(pageinfo);
    }

    public ServerResponse informationInfo(Long id){
        NewsManager informationWithBLOBs = newsManagerMapper.getInfoAndUserList(id);
        return  ServerResponse.createBySuccess(informationWithBLOBs);
    }



}
